<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: account_lostpw.php 33234 2015-03-30 11:40:43Z mpage $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

if(submitcheck('lostpwsubmit')) {
	
	if(!preg_match('/^(\+)?(86)?0?1\d{10}$/', $_GET['mobile'])) {
		showmessage('dzapp_base:mobile_illegal');
	}

	$member = C::t('#dzapp_mobile#dzapp_mobile_member')->fetch_by_mobile($_GET['mobile']);
	if(empty($member)) {
		showmessage('dzapp_base:mobile_unregistered');
	}

	if(empty($_GET['code'])) {
		showmessage('dzapp_base:code_invalid');
	}

	$sms = C::t('#dzapp_sms#dzapp_sms')->fetch_by_type_mobile('reg_code', $_GET['mobile']);
	if($sms['code'] != $_GET['code']) {
		showmessage('dzapp_base:code_incorrect');
	}

	$password = random(6, 1);
	loaducenter();
	uc_user_edit(addslashes($member['username']), null, $password, null, 1);
	require DISCUZ_ROOT.'./source/plugin/dzapp_sms/function/function_sms.php';
	send_sms('lost_password', $_GET['mobile'], array('password' => $password));

	showmessage('dzapp_base:getpasswd_send_succeed', $_G['siteurl'], array(), array('showdialog' => 1, 'locationtime' => true));
}

?>